<?php 
include $_SERVER['DOCUMENT_ROOT'].'/inc/core/class/StyleCss.php';

class Head {
	private $html = '';
	
	function __construct() {
		global $_TAG_REPLACE, $_SITE;
		
		$css = new StyleCss();
		$this->html = file_get_contents($_SITE['path']['dir']['blocks']['container'].'/head.tag.html');
		$this->html = str_replace($_TAG_REPLACE["head_css"], $css->html(), $this->html);
	}
	
	function html() {	
		return $this->html;
	}
	
	function setTitle ($str) {
		global $_TAG_REPLACE, $_ENV;
		
		if (!empty($_ENV["var"]["head"]["title_dinamic"])) {
			$str = str_replace($_TAG_REPLACE["head_title_dinamic"], $_ENV["var"]["head"]["title_dinamic"], $str);
		}
		
		$this->html = str_replace($_TAG_REPLACE["head_title"], '<title>'.$str.'</title>', $this->html);
	}
	
	function setDescription ($str) {
		global $_TAG_REPLACE, $_ENV;
		
		if (!empty($_ENV["var"]["head"]["description_dinamic"])) {
			$str = str_replace($_TAG_REPLACE["head_description_dinamic"], $_ENV["var"]["head"]["description_dinamic"], $str);
		}
		$this->html = str_replace($_TAG_REPLACE["head_description"], '<meta name="description" content="'.$str.'" />', $this->html);
	}
	
	function setKeywords ($str) {
		global $_TAG_REPLACE, $_ENV;
		
		if (!empty($_ENV["var"]["head"]["keywords_dinamic"])) {
			$str = str_replace($_TAG_REPLACE["head_keywords_dinamic"], $_ENV["var"]["head"]["keywords_dinamic"], $str);
		}
		$this->html = str_replace($_TAG_REPLACE["head_keywords"], '<meta name="keywords" content="'.$str.'" />', $this->html);
	}
	
	function setAuthor ($str) {
		global $_TAG_REPLACE;
		$this->html = str_replace($_TAG_REPLACE["head_author"], '<meta name="author" content="'.$str.'" />', $this->html);
	}
	
} 
?>